<template>
    <div id="addrole">
        角色管理
   <el-card class="box-card">
   <!-- 菜单导航栏 -->
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
    <el-tab-pane label="角色基本信息" name="first">
<!-- 表单 -->
  <el-form :model="addRoleFrom" ref="RoleFroms">
    <el-form-item label="角色名称:" prop="name">
      <el-input v-model="addRoleFrom.name" />
    </el-form-item>
     <el-form-item label="角色类型:" prop="roletype">
     <el-select v-model="addRoleFrom.roletype"  placeholder="请选择" size="large">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
    </el-form-item>
    <el-form-item label="角色描述:" prop="nameactive">
      <el-input v-model="addRoleFrom.nameactive" type="textarea" maxlength="500"  show-word-limit/>
    </el-form-item>
  </el-form>
<el-button type="success" size="small" @click="nextBtn" class="nextBtn">下一页</el-button>
    </el-tab-pane>
    <el-tab-pane label="角色操作权限" name="second" >
        <el-tree :data="roleqxList" :props="roleTree" show-checkbox node-key="id"  :default-expanded-keys="[1]" @check="currentCheck" />
        <el-button type="success" size="small" @click="querBtn" class="nextBtn">确认</el-button>
    </el-tab-pane>
  </el-tabs>
<img src="../assets/imgs/guanbi.png" class="gbImg" @click="tcBtn"/>
 
  </el-card>

        
    </div>
</template>

<script>
import {toRefs } from 'vue'
import { ElCard } from 'element-plus'
import { useCounterStore } from "../store";
export default {
     components:{
        ElCard
    },
    setup() {
      const store = useCounterStore()
       //获取树形控件所选节点数据
    const currentCheck =(nodeObj,SelectedObj) =>{
     store.currentChecks(nodeObj,SelectedObj)
        }
      //退出添加角色页面
      const tcBtn = () =>{
     store.tcBtns()
      }
      //下一页按钮
      const nextBtn = () =>{
        store.nextye()
      }
      //确认添加角色按钮
      const querBtn = () =>{
        store.querBtns()
      }
     //获取添加角色的树形控件数据
        const getroletrees = () =>{
         store.getroletree()
        }
      return{
        ...toRefs(store),
        nextBtn,
        querBtn,
        tcBtn,
        getroletrees,
        currentCheck
      }
    },
    created(){
      this.getroletrees()
    }
}
</script>

<style lang="less" scoped>
/deep/.el-tabs__nav-wrap::after{
    height: 0px;
    width: 0px;
}
/deep/.el-tabs__nav-scroll {
    width: 250px;
}
/deep/.el-tabs__item{
    padding: 0;
    margin-right: 10px;
    border-bottom: 2px solid #666;
}
.el-tab-pane{

height: 65vh;
position: relative;
}
.el-form-item:nth-child(1){
    width: 200px;
}
.el-form-item:nth-child(2){
    width: 200px;
}
.el-form-item:nth-child(3){
    width: 500px;
    /deep/.el-textarea__inner{
        height: 200px;
    }
}
/deep/.el-form-item__label{
    font-size: 0.5rem;
    font-weight: bold
}
.el-card{
    position: relative;
    height: 80vh;
}
.gbImg{
    width: 20px;
    height: 20px;
    position: absolute;
    right: 20px;
    top: 20px;
}
.nextBtn{
    position: absolute;
     right: 40px;
  bottom: 20px;
}
</style>